/**
 * @Title: loading.js
 * @Description: loading
 * @author: LoveCrossZhu
 * @date: 2020/8/2 11:39 PM
 * @version V1.0
 */
let LoadingUtil = {
    showLoading(timeOut = 10000) {
        this.startShowLoading();
        this.timerLoading = setTimeout(() => {
            this.dismissLoading();
        }, timeOut);
    },
    /**
     * 延迟500ms显示loading动画
     * @param delay 延迟ms数
     */
    showLoadingDelay(delay = 500) {
        this.timerLoading && clearTimeout(this.timerLoading);
        this.dissTimer && clearTimeout(this.dissTimer);
        this.timerLoading = setTimeout(() => {
            this.startShowLoading();
        }, delay);
        this.dissTimer = setTimeout(() => {
            this.dismissLoading();
        }, 60000);
    },
    startShowLoading() {
        global.mLoadingComponentRef && global.mLoadingComponentRef.showLoading();
    },
    dismissLoading() {
        global.mLoadingComponentRef && global.mLoadingComponentRef.dismissLoading();
        this.timerLoading && clearTimeout(this.timerLoading);
        this.dissTimer && clearTimeout(this.dissTimer);
    },
};

export default LoadingUtil;